cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)

set(CMAKE_CXX_STANDARD 11)

# Download and unpack googletest at configure time
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
  RESULT_VARIABLE result
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
if(result)
  message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
  RESULT_VARIABLE result
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
if(result)
  message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
                 ${CMAKE_BINARY_DIR}/googletest-build)

include_directories(src)

# Link runTests with what we want to test and the GTest and pthread library
add_executable(sort-tests test/test.cpp
                          test/sort/insertion.cpp
                          test/sort/qsort.cpp
                          test/sort/bubble.cpp
                          test/sort/select.cpp
                          test/sort/shell.cpp
                          test/sort/merge.cpp
                          test/sort/heap.cpp)
target_link_libraries(sort-tests gtest_main)

add_executable(linkedlist-tests test/test.cpp test/linkedlist.cpp)
target_link_libraries(linkedlist-tests gtest_main)

add_executable(hashmap-tests test/test.cpp test/hashmap.cpp)
target_link_libraries(hashmap-tests gtest_main)
